<?php

declare(strict_types=1);

namespace App\Fastapp\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\DbConnection\Db;
use Psr\Container\ContainerInterface;

#[Command]
class FastappInitCommand extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('fastapp:init');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('初始化后台账号');
    }

    public function handle()
    {
        $tm = date('Y-m-d H:i:s');
        $pwd = password_hash('fastapp', PASSWORD_DEFAULT);
        $s = "INSERT INTO `system_user` (id, username, password, user_type, nickname, phone, email, avatar, signed, dashboard, status, login_ip, login_time, backend_setting, created_by, updated_by, created_at, updated_at, deleted_at, remark) VALUES(1, 'fastapp', '$pwd', '100', '深色的海', '17612870893', 'telegram:deepsea159', '', 'fastapp', 'statistics', 1, '127.0.0.1', '$tm', NULL, 0, 1, '$tm', '$tm', NULL, NULL);";
        Db::insert($s);
    }
}
